/*
 * Created on May 19, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.jjprojects.earutility;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.BorderFactory;
import javax.swing.JTextField;
import javax.swing.border.Border;

/**
 * @author U678864 TODO To change the template for this generated type comment
 *         go to Window - Preferences - Java - Code Style - Code Templates
 */
public class RoundTextField extends JTextField
{
    private Color colStartGradient = Color.WHITE;
    private Color colEndGradient = Color.BLACK;
    private boolean boolGradientText = false;
    
    public RoundTextField(int cols, Color colStartGradient, Color colEndGradient
            , boolean boolGradientTextField)
    {
        super(cols);
        this.boolGradientText  = boolGradientTextField;
        this.colStartGradient = colStartGradient;
        this.colEndGradient = colEndGradient;
        
        setOpaque(false);
        setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    }
    
    public Color getGradientEndColor()
    {
        return colEndGradient;
    }
    public void setGradientEndColor(Color colGradientEnd)
    {
        this.colEndGradient = colGradientEnd;
    }
    public Color getGradientStartColor()
    {
        return colStartGradient;
    }
    public void setGradientStartColor(Color colGradientStart)
    {
        this.colStartGradient = colGradientStart;
    }
    public boolean isGradientText()
    {
        return boolGradientText;
    }

    protected void paintComponent(Graphics g)
    {
        int width = getWidth();
        int height = getHeight();

        if(this.boolGradientText)
        {
            GradientPaint gradient = new GradientPaint(0, 0, colStartGradient,  width, height, colEndGradient);
            Graphics2D g2d = (Graphics2D)g;
            g2d.setPaint(gradient);
            g2d.fillRoundRect(0, 0, width, height, height, height);
        }
        else
        {
            g.fillRoundRect(0, 0, width, height, height, height);
        }
        
        super.paintComponent(g);
    }
    
    public void setBorder(){}
    public void setBorder(Border b){}
}
